BP008: Replace con* functions by Annotated versions
https://github.com/pydantic/bump-pydantic#bp008-replace-con-functions-by-annotated-versions
constr(min_length=1)はAnnotated[str, StringConstraints(min_length=1)]となる
https://docs.pydantic.dev/latest/migration/#defining-custom-types
Composing types via Annotated https://docs.pydantic.dev/latest/usage/types/custom/#composing-types-via-annotated
https://docs.pydantic.dev/latest/usage/types/strict_types/#constrained-types
You can also use pydantic.StringConstraints in Annotated instead of constr for better compatibility with type checkers and more flexibility in nesting within other types:
以下への改善なのかな
code:mypy_message
error: Invalid type comment or annotation valid-type
note: Suggestion: use constr... instead of constr(...)
error: Invalid type comment or annotation valid-type
note: Suggestion: use conlist... instead of conlist(...)
typing.Annotated
from pydantic import StringConstraintsできない(Pydantic v2.0.3)
https://github.com/pydantic/pydantic/pull/6605
上のプルリクエストはマージされているが、ドキュメントに反映されただけでリリースされていない